//
// Created by bbnf on 09.06.2024.
//

#ifndef TODOAPPCPP_FILE_PARSER_H
#define TODOAPPCPP_FILE_PARSER_H

#include "storage_pch.h"

namespace TodoApp::Storage::FileStorage {
    class FileParser {
    private:
        std::filesystem::path m_path;
    public:
        struct TodoDto {
            bool done;
            std::string title;
            std::string description;
            int64_t done_time;
            std::int8_t priority;
        };

        explicit FileParser(std::filesystem::path path);

        virtual ~FileParser() = default;

        virtual auto parse() -> std::vector<TodoDto> = 0;

        [[nodiscard]] auto path() const -> std::filesystem::path { return m_path; }
    };

    class TxtFileParser : public FileParser {

    public:
        auto parse() -> std::vector<TodoDto> override;

        [[maybe_unused]] explicit TxtFileParser([[maybe_unused]] std::filesystem::path path);

        ~TxtFileParser() override = default;

    private:
        auto explode(std::string separator, std::string line) const -> std::vector<std::string>;
    };
}  // namespace TodoApp::Storage::FileStorage

#endif //TODOAPPCPP_FILE_PARSER_H
